//- Copyright (C) 2023 Beijing Huaxia Chunsong Technology Co., Ltd. 
//- <https://www.chatopera.com>, Licensed under the Chunsong Public 
//- License, Version 1.0  (the "License"), https://docs.cskefu.com/licenses/v1.html
//- Unless required by applicable law or agreed to in writing, software
//- distributed under the License is distributed on an "AS IS" BASIS,
//- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//- See the License for the specific language governing permissions and
//- limitations under the License.
//- Copyright (C) 2018-Jun. 2023 Chatopera Inc, <https://www.chatopera.com>
//- Licensed under the Apache License, Version 2.0
//- http://www.apache.org/licenses/LICENSE-2.0
.uk-layui-form
    form.layui-form.uk-form(action='/admin/metadata/properties/update.html')
        input(type='hidden', name='id', value=tp.id)
        .layui-form-item
            label.layui-form-label 标题：
            .layui-input-inline
                input.layui-input(type='text', name='name', value=tp.name, required, lay-verify='required', placeholder='标题', autocomplete='off')
        .layui-form-item
            .layui-inline
                label.layui-form-label 禁用导入导出：
                .layui-input-inline(style='line-height: 25px;width:80px;')
                    input(type="checkbox", name="impfield", lay-skin="switch", value="1", checked=(tp.impfield == true ? 'checked' : false),lay-text="开启|关闭" )
            .layui-inline
                label.layui-form-label(style='width:100px;') 生成ID：
                .layui-input-inline(style='line-height: 25px;width:80px;')
                    input(type="checkbox", name="pk", lay-skin="switch", value="1", checked=(tp.pk == true ? 'checked' : false),lay-text="开启|关闭" )
        .layui-form-item
            .layui-inline
                label.layui-form-label 启用字典：
                .layui-input-inline(style='line-height: 25px;width:80px;')
                    input(type="checkbox", name="seldata", lay-filter="dic", lay-skin="switch", value="1", checked=(tp.seldata == true ? 'checked' : false),lay-text="开启|关闭" )
            .layui-inline#sysdicsel(style='<#if tp.seldata == false>display:none;</#if>')
                label.layui-form-label(style='width:60px;') 字典项：
                .layui-input-inline
                    select(name='seldatacode', lay-ignore, style='width:220px;')
                        option(value) 请选择字典项
                        for sysDic in sysdicList
                            option(value=sysDic.code, selected=((tp.seldatacode && tp.seldatacode == sysDic.code) ? 'selected' : false) )= sysDic.name
        .layui-form-item
            .layui-inline
                label.layui-form-label 启用流程变量：
                .layui-input-inline(style='line-height: 25px;width:80px;')
                    input(type="checkbox", name="systemfield", lay-skin="switch", value="1", checked=(tp.systemfield == true ? 'checked' : false),lay-text="开启|关闭" )
            .layui-inline
                label.layui-form-label(style='width:100px;') 启用多值：
                .layui-input-inline(style='line-height: 25px;width:80px;')
                    input(type="checkbox" name="modits" lay-skin="switch" value="1", checked=(tp.modits == true ? 'checked' : false),lay-text="开启|关闭" )
        .layui-form-item
            .layui-inline
                label.layui-form-label 启用关联：
                .layui-input-inline(style='line-height: 25px;width:80px;')
                    input(type="checkbox" name="reffk" lay-skin="switch" lay-filter="fk" value="1" , checked=(tp.reffk == true ? 'checked' : false),lay-text="开启|关闭" )
            .layui-inline#fk(style='<#if tp.reffk?? && tp.reffk><#else>display:none;</#if>', lay-ignore)
                label.layui-form-label(style='width:60px;') 关联表：
                .layui-input-inline(style='line-height: 25px;width:80px;')
                    select(name='reftbid', lay-ignore, style='width:220px;')
                        option(value) 请选择数据接口
                        for datadic in dataImplList
                            option(value=datadic.code, selected=((tp.reftbid && tp.reftbid == datadic.code) ? 'selected' : false) )= datadic.name
        .layui-form-item
            .layui-inline
                label.layui-form-label 数据校验：
                .layui-input-inline(style='line-height: 25px;width:380px;margin-top:0px;')
                    input(type="checkbox", name="defaultvaluetitle", title="非空", value="required", lay-skin="primary",  checked=(tp.defaultvaluetitle.contains('required') ? 'checked' : false))
                    input(type="checkbox", name="defaultvaluetitle", title="数字", value="numstr", lay-skin="primary",  checked=(tp.defaultvaluetitle.contains('numstr') ? 'checked' : false))
                    input(type="checkbox", name="defaultvaluetitle", title="日期", value="datenum", lay-skin="primary",  checked=(tp.defaultvaluetitle.contains('datenum') ? 'checked' : false))
                    input(type="checkbox", name="defaultvaluetitle", title="日期时间", value="datetime", lay-skin="primary",  checked=(tp.defaultvaluetitle.contains('datetime') ? 'checked' : false))
        .layui-form-item
            .layui-inline
                label.layui-form-label 转日期：
                .layui-input-inline(style='line-height: 25px;width:380px;margin-top:0px;')
                    input(type="checkbox" name=defaultfieldvalue lay-skin="switch" value="date", checked=((tp.defaultfieldvalue && tp.defaultfieldvalue == "date") ? 'checked' : false),lay-text="开启|关闭" )
        .layui-form-button
            .layui-button-block
                button.layui-btn(lay-submit, lay-filter='formDemo') 立即提交
                button.layui-btn.layui-btn-original(type='reset') 重置
script.
    layui.use('form', function () {
        var form = layui.form();
        form.render(); //更新全部
        form.on("switch(dic)", function (data) {
            if (data.elem.checked) {
                $("#sysdicsel").show();
            } else {
                $("#sysdicsel").hide();
            }
        });
        form.on("switch(fk)", function (data) {
            if (data.elem.checked) {
                $("#fk").show();
            } else {
                $("#fk").hide();
            }
        });
    });

